package org.feiye.studyday24;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class InPutOutPutTset {

	public static void main(String[] args) {
		InputStream i = null;
		OutputStream o = null;
		try {
			i = new FileInputStream("F:\\叶飞io测试\\hello.txt");
			o = new FileOutputStream("F:\\叶飞io测试\\China.txt", true);
			int available = i.available();
			byte[] b = new byte[available];
			int r;
			if ((r = i.read(b)) > -1) {
				o.write(b, 0, r);
				System.out.println("文件复制已完成!");
			}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (o != null)
				try {
					o.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			if (i != null)
				try {
					i.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}

}
